﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KaroInterface;

namespace Emerald
{
    class RandomAI : AI
    {
        Random r = new Random();

        public override string DoTurn(string gameStateString)
        {
            GameState g = new GameState(gameStateString);

            IAction a;

            if (g.CountPieces(Color.ToString()) < 6)
            {
                a = CalculateRandomAdd(g);
                Console.WriteLine("Adding a piece: " + a.ToString());

            }
            else
            {

                GameState[] gsts = g.NextPossibleStates(1);
                
                a = gsts[r.Next(gsts.Count(gs => gs != null))].CreationMove;

#if DEBUG
                Console.WriteLine("Moving a random piece: " + a.ToString());
#endif
            }

            return a.DataString;
        }
    }
}
